package demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: WHY
 * Date: 2022-06-21
 * Time: 17:18
 */
 abstract  class  Animal {
    public String name;
    public int    age;
    public   Animal(String name,int age ){
        this.name=name;
        this.age=age;
    }
    public  abstract void eat();

}
class Cat extends Animal{

    public Cat(String name, int age) {
        super(name, age);
    }

    @Override
    public void eat() {
        System.out.println(name+"正在吃饭");
    }

}
class  Cow  extends Animal {

    public Cow(String name, int age) {
        super(name, age);
    }

    @Override
    public void eat() {
        System.out.println(name+"正在吃饭");
    }
}


public class Test {
     public static void behavior(Animal animal){
         animal.eat();
     }


    public static void main(String[] args) {
        Cat  cat=new Cat("猫猫",1);
        Cow  cow=new Cow("牛牛",3);
        behavior(cat);
        behavior(cow);

    }
}
